clear all; clc; close  all;
Fd = 44.2e6/4; Td = 1/Fd;
tmax = 0.001; t = 0:Td:tmax;

N_PRN = 511; T_PRN = 0.001;
PRN = sign(randn(1, N_PRN));
ind_h = fix(mod(t/T_PRN, 1)*N_PRN) + 1;
h = PRN(ind_h);

A = 2;
f0 = 3e6;
phi = pi/4;

u = A * h .* cos(2*pi*f0*t + phi);


Tc=0.001;
qcno_dB=45;

stdn_IQ=8;
nI=stdn_IQ*randn(1,1);
nQ=stdn_IQ*randn(1,1);


[A_IQ qcno]=qcno_change(qcno_dB, stdn_IQ(k),Tc);
A_IQ_eff(k)=A_IQ(k)*sinc(EpsW*Tc/2 /pi)*ro(EpsTau);
mI=A_IQ_eff(k)*cos(EpsW*Tc/2 + EpsPhi);
mQ= -A_IQ_eff(k)*sin(EpsW*Tc/2 +EpsPhi);
I=mI+nI;
Q=mQ+nQ;



function[A_IQ qcno]=qcno_change(qcno_dB, stdn_IQ, Tc)
qcno=10.^(qcno_dB/10);
A_IQ=stdn_IQ.*sqrt(2*qcno*Tc);
end


function  f=ro(x)
global TauChip
f=(abs(x)<TauChip).*(1-abs(x)/TauChip);
end



